<!-- CourseCenter_CourseCategory.html -->
<!DOCTYPE html>

	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
		<title>岗位分类列表</title>
		<link rel="stylesheet" type="text/css" href="../../css/api.css" />
		<link rel="stylesheet" href="../../css/weui.min.css">
		<link rel="stylesheet" href="../../css/mui.min.css"/>
		<link rel="stylesheet" href="../../css/base.css"/>
		<link rel="stylesheet" href="../../css/CFNetPP_Base.css">
		<style type="text/css">
			html,body{
				background-color: rgba(0,0,0,0);
			}
			.mui-table-view-cell{
				padding: 10px 10px;
			}
			.selected-cell{
				color: #18b4ed;
				background-color: #f3f5f6;
			}
			.mui-table-view-cell{
				line-height: 24px;
			}
			.mui-table-view {
    position: relative;
    margin-top: 0;
    margin-bottom: 0;
    padding-left: 0;
    list-style: none;
    background-color: #fff;
    width: 50%;
    float: left;
}
#category_list2{
background-color: #f3f5f6;
}
			
		</style>
	</head>
	<body>
	
    	<ul id="category_list" class="mui-table-view">
    	<!--	<li id="0" class="mui-table-view-cell base_content_font base_dark_grey">
    			全部
	    	</li>
	    	<li id="0" class="mui-table-view-cell base_content_font base_dark_grey" >
    			全部2
	    	</li>-->
	    	
	    	
    	</ul>
    	<ul id="category_list2" class="mui-table-view"  >
    		<!--<li id="0" class="mui-table-view-cell base_content_font base_dark_grey">
    			全部222222222
	    	</li>
	    	<li id="0" class="mui-table-view-cell base_content_font base_dark_grey" >
    			全部233333333
	    	</li>
	    		<li id="0" class="mui-table-view-cell base_content_font base_dark_grey">
    			全部3444444444
	    	</li>-->
    	</ul>
    	
	</body>
	<!-- <script type="text/javascript" src="../../script/mui.min.js"></script> -->
	<script type="text/javascript" src="../../script/jquery.min.js"></script>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/MD5.js"></script>
	<script type="text/javascript" src="../../script/requestTool.js"></script>
	<script type="text/javascript">
	 
		var currentCategoryId = '';
		var warehousename = '';
	    var cid = '';//企业id
		apiready = function(){
		    loadCategoryOneData();
		   
		}
		//一级分类
		function loadCategoryOneData(){
			var param = {
				uid : $api.getStorage('cfnetppuid'),
				jid : $api.getStorage('cfnetppjid'),
			};
			cfnetppPOST(urlhrqylst, param, true, function(data, status){
				if (status == 'success') {
					if (data.code == 200) {
						var categoryArr = data.data;
						if (categoryArr != null && categoryArr.constructor == Array && categoryArr.length > 0) {
							var categoryHtmlString = '<li id="0" class="mui-table-view-cell base_content_font base_dark_grey  mui-table-view-cell1 selected-cell ">全部</li>';
							for (var i = 0; i < categoryArr.length; i++) {
								var categoryData = categoryArr[i];
								categoryHtmlString += categoryCellHtml(categoryData, i);
							}
							$('#category_list').html(categoryHtmlString);
							setupCellClick();
						}
					}
				}
			});
		}
			//二级分类
		function loadCategoryTwoData(cid){
			var param = {
				uid : $api.getStorage('cfnetppuid'),
				jid : $api.getStorage('cfnetppjid'),
				cid :cid
			};
//			console.log(JSON.stringify(param));
			cfnetppPOST(urlhrqygwlst, param, true, function(data, status){
				if (status == 'success') {
					if (data.code == 200) {
						var categoryArr = data.data;
						if (categoryArr != null && categoryArr.constructor == Array && categoryArr.length > 0) {
							var categoryHtmlString = '<li id="00" class="mui-table-view-cell base_content_font base_dark_grey mui-table-view-cell2">全部</li>';
//							alert(categoryArr.length);
							for (var i = 0; i < categoryArr.length; i++) {
								var categoryData = categoryArr[i];
								categoryHtmlString += categoryTwoCellHtml(categoryData, i);
							}
							$('#category_list2').html(categoryHtmlString);
							setupTwoCellClick();
						}
					}
				}
			});
		}
		function categoryCellHtml(data, index){
			if (data.categoryName == '') {
				return '';
			}
			var selectedClass = '';
//			if ((api.pageParam.categoryid == null && index == 0) || api.pageParam.categoryid == data.categoryid) {
//				selectedClass = ' selected-cell';
//			}
			return '<li id="'+data.cid+'" class="mui-table-view-cell base_content_font base_dark_grey mui-table-view-cell1'+selectedClass+'">'+
	    			data.names+
		    	'</li>';
		}
		function categoryTwoCellHtml(data, index){
			if (data.categoryName == '') {
				return '';
			}
			var selectedClass = '';
//			if ((api.pageParam.categoryid == null && index == 0) || api.pageParam.categoryid == data.categoryid) {
//				selectedClass = ' selected-cell';
//			}
			return '<li id="'+data.gwid+'" class="mui-table-view-cell base_content_font base_dark_grey mui-table-view-cell2'+selectedClass+'">'+
	    			data.gwname+
		    	'</li>';
		}
//		function setupBgClick(){
//			$('#category_html').click(function(){
//				api.setFrameAttr({
//				    name: 'CourseCenter_CourseCategory',
//				    hidden: true
//				});
//			});
//		}
		function setupCellClick(){
			$('.mui-table-view-cell1').unbind('click');
			$('.mui-table-view-cell1').click(function(event){
				event.stopPropagation();
				var cId = $(this).attr('id');
				var cTitle = $(this).text();
				$('.mui-table-view-cell1').removeClass('selected-cell');
				$('#'+cId).addClass('selected-cell');
				if(cId == 0){//全部
				api.sendEvent({
				    name: 'jobCategoryNotifi',
				    extra: {
				       cId: cId, 
				        cTitle: cTitle
				    }
				});
				api.setFrameAttr({
				    name: 'CourseCategoryWind',
				    hidden: true
				});
				$("#category_list2").hide();
				}else{//二级分类
				 warehouse = cTitle;
				 cid  = cId;
				loadCategoryTwoData(cId);
			    }
			   });
			
			
		}
		function setupTwoCellClick(){
			$('.mui-table-view-cell2').unbind('click');
			$('.mui-table-view-cell2').click(function(event){
				event.stopPropagation();
				var gId = $(this).attr('id');
				var cTitle = $(this).text();
				$('.mui-table-view-cell2').removeClass('selected-cell');
			
				if(gId == 0){//全部
				  $('#'+gId).addClass('selected-cell');
				
				}else{//二级分类
				$('#'+gId).addClass('selected-cell');
			    }
			    api.sendEvent({
				    name: 'jobCategoryNotifi',
				    extra: {
				        cId: cid, 
				        warehouse :warehouse,
				        gId:gId,
				       cTitle: cTitle,
				        
				    }
				});
				api.setFrameAttr({
				    name: 'CourseCategoryWind',
				    hidden: true
				});
			   });
			
			
		}
	</script>
</html>